const day = 3; // 假设1=周一，2=周二，...，7=周日
let dayName;
switch(day) {
    case 1:
        dayName = "周一";
        break;
    case 2:
        dayName = "周二";
        break;
    case 3:
        dayName = "周三";
        break;
    case 4:
        dayName = "周四";
        break;
    case 5:
        dayName = "周五";
        break;
    case 6:
        dayName = "周六";
        break;
    case 7:
        dayName = "周日";
        break;
    default:
        dayName = "无效的日期";
}
console.log(dayName); // 输出："周三"
//处理字符串匹配
const fruit = "apple";
let message;
switch(fruit) {
    case "banana":
        message = "香蕉富含钾元素";
        break;
    case "apple":
        message = "一天一苹果，医生远离我";
        break;
    case "orange":
        message = "橙子富含维生素C";
        break;
    default:
        message = "未知水果";
}
console.log(message); // 输出："一天一苹果，医生远离我"
let score = 75;
// 用switch实现根据成绩输出等级
// 表达式写 true，case 中写范围判断（利用了 switch 的 === 比较）
switch(true) {
    case score >= 90:
        console.log("优秀");
        break;
    case score >= 80:
        console.log("良好");
        break;
    case score >= 60:
        console.log("及格");
        break;
    default:
        console.log("不及格");
}